/**
 * Created by xie on 2018/4/8.
 */
angular.module('module.personalcenter')
    .controller('CommentController', CommentController);

CommentController.$inject = ['$scope','$state','$cookies','$rootScope','PersonalcenterService'];

function CommentController($scope, $state,$cookies, $rootScope,PersonalcenterService) {
    var vm = this;
    vm.user=JSON.parse($cookies.get("userInfo"));
    vm.goArticle=goArticle;
    vm.deleteComment=deleteComment;
    PersonalcenterService.getCommentByUserid(vm.user.userid).$promise.then(function(data){
        vm.comments = data;
    },function(err){
        console.log(err)
    });

    function goArticle(id){

        $state.go("atricle",{articleid:id});
    }

    function deleteComment(commentid) {
        if (confirm("是否删除此评论？")) {
            PersonalcenterService.deleteCommentById(commentid).$promise.then(function (data) {
                request = data;
                javascript:history.back(-1);
            }, function (err) {
                console.log(err)
            });
        }
    }
}